<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<?php
$id = rand(0,1000);

?>
<div id="main-{{$id}}" style="width: 100%;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main-{{$id}}'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '24小时数据'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: [@foreach($data as $key => $item) '{{ $key }}',@endforeach]
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: [@for($i=0;$i<=date('H',time());$i++){{ $i.',' }} @endfor]
        },
        yAxis: {
            type: 'value'
        },
        series: [

                @foreach($data as $key => $items)
            {
                name: '{{$key}}',
                type: 'line',
                data: [@foreach($items as $item) '{{ $item }}',@endforeach],
                smooth: true,
                itemStyle: {
                    normal: {
                        label: {
                            show: true
                        }
                    }
                }
            },
            @endforeach
        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
